<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/5
 * Time: 14:20
 */

namespace App\Http\Traits;


use Illuminate\Http\Request;

trait MenuTrait
{
    use BaseTrait;

    // 菜单ID
    protected $id;
    // 验证秘钥
    protected $loginSession;
    // 父ID
    protected $parent_id;
    // 菜单名称
    protected $name;
    // 菜单路径
    protected $path;
    // 分页大小
    protected $limit;
    // 菜单类型
    protected $type;
    // 菜单图标文件
    protected $icon_file;
    // 菜单图标文件
    protected $icon;
    // 菜单ID字符串
    protected $menu_id_str;
    // 用户ID
    protected $user_id;
    // 是否有二维码
    protected $has_qrcode;
    // 菜单ID
    protected $menu_id;
    // 合作者Key
    protected $key;
    // 权限ID
    protected $auth_id;

    public function __construct(Request $request)
    {
        $this->id = $request->input('id', 0);
        $this->loginSession = $request->input('loginSession', '');
        $this->parent_id = $request->input('parent_id', 0);
        $this->name = $request->input('name', '');
        $this->path = $request->input('path', '');
        $this->limit = $request->input('limit', 0);
        $this->type = $request->input('type', '');
        if (!empty($request->file('file', ''))){
            $this->icon_file = $request->file('file', '')->store('temp');
        }
        $this->icon = $request->input('icon', '');
        $this->menu_id_str = $request->input('menu_id_str', '');
        $this->user_id = $request->input('user_id', 0);
        $this->has_qrcode = $request->input('has_qrcode', '');
        $this->menu_id = $request->input('menu_id', 0);
        $this->key = $request->input('key', '');
        $this->auth_id = $request->input('auth_id', 0);
    }
}